-
Notifications
You must be signed in to change notification settings - Fork 20.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
core: fix pre-check for account balance under EIP-1559 #23244
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @MariusVanDerWijden !
@@ -193,6 +193,7 @@ func (st *StateTransition) buyGas() error { | |||
if st.gasFeeCap != nil { | |||
balanceCheck = new(big.Int).SetUint64(st.msg.Gas()) | |||
balanceCheck = balanceCheck.Mul(balanceCheck, st.gasFeeCap) | |||
balanceCheck.Add(balanceCheck, st.value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just FYI this change makes this comment stale
go-ethereum/core/state_transition.go
Line 267 in f68a68a
// 2. caller has enough balance to cover transaction fee(gaslimit * gasprice) |
When processing a transaction with London fork rules, EIP-1559 mandates checking that the sender must have sufficient balance to cover gas * gasFeeCap. In the EIP's pseudocode, this check happens after the value transferred by the transaction has already been deducted. However, in go-ethereum, the balance has not yet been updated when the check happens, and therefore needs to be added explicitly. Co-authored-by: Martin Holst Swende <[email protected]>
When processing a transaction with London fork rules, EIP-1559 mandates checking that the sender must have sufficient balance to cover gas * gasFeeCap. In the EIP's pseudocode, this check happens after the value transferred by the transaction has already been deducted. However, in go-ethereum, the balance has not yet been updated when the check happens, and therefore needs to be added explicitly. Co-authored-by: Martin Holst Swende <[email protected]>
When processing a transaction with London fork rules, EIP-1559 mandates checking that the sender must have sufficient balance to cover gas * gasFeeCap. In the EIP's pseudocode, this check happens after the value transferred by the transaction has already been deducted. However, in go-ethereum, the balance has not yet been updated when the check happens, and therefore needs to be added explicitly. Co-authored-by: Martin Holst Swende <[email protected]>
core: fix pre-check for account balance under EIP-1559 (ethereum#23244) See merge request dongwei/blockchain-go-ethereum!3
We need to account for the value transacted in the buyGas() stage, since it would otherwise
mean our check would be
assert balance >= maxFeePerGas * gas
instead of
assert balance >= tx.value + maxFeePerGas * gas